import http from '../../../common/httpUtil';
import * as types from './bankMutationTypes';

const actions = {
  queryBanks({commit}) {
    commit(types.SYS_FILE_UPLOAD_QUERY_FILES_BEGIN);

    return http.get(`banklimit/all`).then(data => {
      console.log(data)
      var banks = data
      commit(types.SYS_FILE_UPLOAD_QUERY_FILES_SUC, {banks});
    });
  },
  addBank({commit}, {formData}) {
    return http.post(`banklimit?bankCode=${formData.bankCode}&channel=${formData.channel}&bankName=${formData.bankName}&singleLimit=${formData.singleLimit}&dayLimit=${formData.dayLimit}&monthLimit=${formData.monthLimit}&state=${formData.state}`).then(data => {
      console.log(data)
      var newdata = formData
      commit(types.SYS_FILE_UPLOAD_SAVE_FILE_SUC, {newdata})
    });
  },
  editBank({commit}, {formData}) {
    // return http.post(`banklimit/update?id=${formData.id}&singleLimit=${formData.singleLimit}&dayLimit=${formData.dayLimit}&monthLimit=${formData.monthLimit}&state=${formData.state}`).then(data => {
    //   console.log(data)
    //   commit(types.SYS_FILE_UPLOAD_UPDATE_SUC, {formData})
    //   return data
    // });
    return http.post(`banklimit/update`, formData).then(data => {
      console.log(data)
      commit(types.SYS_FILE_UPLOAD_UPDATE_SUC, {formData})
      return data
    });
  },
  delBank({commit}, {id}) {
    return http.post(`banklimit/delete?id=${id}`).then(data => {
      commit(types.SYS_FILE_UPLOAD_DELETE_SUC, {id})
    });
  }
};


export default actions;
